<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>传递给脚本的参数数组</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reserved.variables.argc.html">$argc</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reserved.exceptions.html">预定义异常</a></div>
 <div class="up"><a href="reserved.variables.html">预定义变量</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="reserved.variables.argv" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">$argv</h1>
  <p class="refpurpose"><span class="refname">$argv</span> &mdash; <span class="dc-title">传递给脚本的参数数组</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-reserved.variables.argv-description">
  <h3 class="title">说明</h3>
  <p class="para">
   包含当运行于<a href="features.commandline.html" class="link">命令行</a>下时传递给当前脚本的参数的数组。
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    第一个参数总是当前脚本的文件名，因此 <var class="varname"><var class="varname">$argv[0]</var></var> 就是脚本文件名。
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    这个变量仅在 <a href="ini.core.html#ini.register-argc-argv" class="link">register_argc_argv</a> 打开时可用。
   </span>
  </p></blockquote>
 </div>

 
 <div class="refsect1 examples" id="refsect1-reserved.variables.argv-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="variable.argv.basic">
    <p><strong>Example #1 <var class="varname"><var class="varname">$argv</var></var> 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$argv</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>
     当使用这个命令执行：php script.php arg1 arg2 arg3
    </p></div>
    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
  [0]=&gt;
  string(10) &quot;script.php&quot;
  [1]=&gt;
  string(4) &quot;arg1&quot;
  [2]=&gt;
  string(4) &quot;arg2&quot;
  [3]=&gt;
  string(4) &quot;arg3&quot;
}
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-reserved.variables.argv-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.getopt.html" class="function" rel="rdfs-seeAlso">getopt()</a> - 从命令行参数列表中获取选项</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reserved.variables.argc.html">$argc</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reserved.exceptions.html">预定义异常</a></div>
 <div class="up"><a href="reserved.variables.html">预定义变量</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
